package com.client.ryt.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.client.ryt.R;
import com.client.ryt.entity.biz.VoucherRecordEntity;

import java.util.List;

/**
 * Created by heyao on 2014/12/10.
 * 充值记录数据适配器
 */
public class VoucherRecordAdapter extends BaseAdapter {
    private Context context;
    private List<VoucherRecordEntity> list;

    public VoucherRecordAdapter(Context context, List<VoucherRecordEntity> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        VoucherRecordEntity hh = list.get(position);
        H h = null;
        if(view==null){
            h = new H();
            view = LayoutInflater.from(context).inflate(R.layout.item_voucher_record, parent, false);
            h.tv_runningnumber = (TextView)view.findViewById(R.id.tv_item_voucher_record_runningnumber);
            h.tv_score = (TextView)view.findViewById(R.id.tv_item_voucher_record_score);
            h.tv_date = (TextView)view.findViewById(R.id.tv_item_voucher_record_date);
            view.setTag(h);
        }else{
            h = (H)view.getTag();
        }
        h.tv_runningnumber.setText(hh.getRunningNumber());
        h.tv_score.setText(hh.getScore());
        h.tv_date.setText(hh.getDate());
        return view;
    }

    class H{
        TextView tv_date;
        TextView tv_score;
        TextView tv_runningnumber;
    }
}
